<?php


namespace App\Http\Controllers\Api;

use App\Constant\ApiV2Constant;
use App\Http\Requests\ApiV2\CategoryRequest;

use App\Services\Business\Models\Category;
use App\Services\Business\Services\CategoryService;
use App\Services\Business\Interfaces\CategoryServiceInterface;
use App\Zesow\Cache\Impl\CateogryCache;
use Illuminate\Http\Request;


class CategoryController extends BaseController
{
    /**
     * @var CategoryService
     */
    protected $categoryService;

    public function __construct(CategoryServiceInterface $categoryService)
    {
        $this->categoryService = $categoryService;
    }

    /**
     * @param Request $request
     *
     * @return \Illuminate\Http\JsonResponse
     * @api {get} /api/v2/course_categories 录播课程分类
     * @apiGroup 录播课
     * @apiVersion v2.0.0
     *
     * @apiSuccess {Number} code 0成功,非0失败
     * @apiSuccess {Object[]} data 数据
     * @apiSuccess {Number} data.id 分类ID
     * @apiSuccess {String} data.name 分类名
     * @apiSuccess {Number} data.parent_id 分类父ID
     * @apiSuccess {Object[]} data.children 子类
     * @apiSuccess {Number} data.children.id 子分类ID
     * @apiSuccess {String} data.children.name 子分类名
     */


    public function tree(Request $request,CateogryCache $cateogoryCache)
    {

        $categories = $cateogoryCache->tree();
        return  $this->successData(compact('categories'));

    }









}
